package _08作业.t2;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 1. 在项目下创建TCP服务器端 ，端口号为8888。
 * ​	2. 等待客户端连接，获取到客户端对象之后，读取客户端传送的数据并输出到控制台。
 */
public class T2Server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket socket = serverSocket.accept();
        InputStream socketInputStream = socket.getInputStream();

        byte[] bytes =new byte[1024];
        int read;
        if ((read=socketInputStream.read(bytes))!=-1){
            System.out.println(new String(bytes,0,read));
        }
        socketInputStream.close();
        socket.close();
    }
}
